package com.yanqu.road.dao.impl.log;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.db.DbParameter;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.log.LogWorldCupKick;
import com.yanqu.road.entity.log.LogWorldCupRecruit;
import com.yanqu.road.entity.log.LogWorldCupSkill;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 足球
 */
public class LogWorldCupDaoImpl extends TempDao {

    public boolean addLogWorldCupSkillList(List<LogWorldCupSkill> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_worldcup_skill(activityId,userId,skillId,oLevel,nLevel,expAdd,time) VALUES(?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (LogWorldCupSkill data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.INTEGER, data.getActivityId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSkillId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getoLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getnLevel()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getExpAdd()));
            para.put(i++, new DbParameter(Types.TIMESTAMP, data.getTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addLogWorldCupKickList(List<LogWorldCupKick> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_worldcup_kick(activityId,userId,quality,skill,score,multValue,time)" +
                " VALUES(?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (LogWorldCupKick data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.INTEGER, data.getActivityId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getQuality()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSkill()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getScore()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getMultValue()));
            para.put(i++, new DbParameter(Types.TIMESTAMP, data.getTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

    public boolean addLogWorldCupRecruitList(List<LogWorldCupRecruit> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getLogDb());
        String sql = "INSERT INTO t_l_worldcup_recruit(activityId,userId,type,quality,skill,reward,placeId,placeLevel,time)" +
                " VALUES(?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (LogWorldCupRecruit data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.INTEGER, data.getActivityId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getQuality()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSkill()));
            para.put(i++, new DbParameter(Types.VARCHAR, data.getReward()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPlaceId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getPlaceLevel()));
            para.put(i++, new DbParameter(Types.TIMESTAMP, data.getTime()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

}
